﻿CREATE PROCEDURE [dbo].[proc_Product_GetList]
(
	@CateOneId int,
	@CateTwoId int
)
as
Begin
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY CateOneId,CateTwoId,Sort) AS Row,
	Id,
	Sort,
	CateOneId,
	(select title from Product_Category where Id=[Product].CateOneId) CateOneName,
	CateTwoId,
	(select title from Product_Category where Id=[Product].CateTwoId) CateTwoName,
	SupplierId,
	(select title from Supplier where Id=[Product].SupplierId) SupplierName,
	Title,
	CostPrice,
	SalePrice,
	Description,
	UpTime,
	SCateOneId,
	xmfx,
	(select Title from Finance_Subject_Parent where Id=[Product].SCateOneId) SCateOneName,
	SCateTwoId,
	(select Title from Finance_Subject_Parent where Id=[Product].SCateTwoId) SCateTwoName,
	SubjectId,
	(select Title from Finance_Subject where Id=[Product].SubjectId) SubjectName
	,isnull(flag,0) as flag
	From [Product] Where (@CateOneId=-1 Or CateOneId=@CateOneId) and (@CateTwoId=0 Or CateTwoId=@CateTwoId)
	)
	Select * From list
End
